<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8"/>
    <title>新增账号</title>
    <link rel="stylesheet" type="text/css" media="all" href="/layui/css/layui.css"/>
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.js"></script>
    <script type="text/javascript" src="/js/myJs.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="/css/common.css"/>
    <link rel="stylesheet" type="text/css" media="all" href="/css/CaseManager.css"/>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>新增账号</legend>
    </fieldset>
</head>
<body>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<div  class="layui-container">
    <div class="layui-row">
        <div class="layui-col-xs-offset3">
            <form id="addEmployee"  class="layui-form layui-form-pane">
                <!--登录名-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">登录名</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="loginName" autocomplete="off"  class="layui-input" />
                    </div>
                </div>

                <!--密码-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">密码</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="password" autocomplete="off"  class="layui-input" />
                    </div>
                </div>

                <!--角色-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">角色:</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <select name="type" id="power">
                            <option value="master" selected="selected">管理员</option>
                            <option value="super">小编</option>
                            <option value="ordinary">普通用户</option>
                        </select>
                    </div>
                </div>
                <!--姓名-->
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label " style="width: 410px">真实姓名</label>
                    <div class="layui-input-inline" style="width: 410px;">
                        <input type="text" name="realName" autocomplete="off"  class="layui-input" />
                    </div>
                </div>
                <!--手机-->
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label " style="width: 410px">手机号</label>
                    <div class="layui-input-inline" style="width: 410px;">
                        <input type="text" name="phone" autocomplete="off"  class="layui-input" />
                    </div>
                </div>

                <!--部门-->
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label " style="width: 410px">部门</label>
                    <div class="layui-input-inline" style="width: 410px;">
                        <input type="text" name="depart" autocomplete="off"  class="layui-input" />
                    </div>
                </div>

                <button type="reset" style="width: 410px;height: 50px" class="layui-btn" lay-filter="add" lay-submit="">上传</button>

            </form>
        </div>
    </div>
</div>
<br/><br/><br/><br/><br/><br/><br/><br/>
<div class="fly-footer layui-col-xs-offset5" >
    <p><a target="_blank">我打 - 资源上传</a> 2018</p>
</div>
</body>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        form.render();
        //监听提交
        form.on('submit(add)', function(data){

            var from= $("#addEmployee");
            var model= serializeObject(from);

            $.ajax({
                type: "post",
                url: "/Request/addEmployee",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(model),
                dataType: "json",
                success: function(data) {
                    layer.alert(data)
                    if (data =="already"){
                        layer.alert("登录名已存在")
                    } else if(data == "true"){
                        layer.confirm('创建成功', function(index){
                            loadPage("/plateForm/Staff_addEmployee");
                        });
                    }else {
                        layer.alert("创建失败");
                        loadPage("#");
                    }

                }
            })
        });
    });
</script>
</html>